<!DOCTYPE html>
<html lang="zh-cn">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
		<style>
			
		</style>
		<script src='./src/vue.js'></script>
	</head>

	<body>
		<div id="app">
			<h2>未来的某个时刻出现第二个组件--动态组件</h2>
			<button @click="view='custom1'">出现custome1</button>
			<button @click="view='custom2'">出现custome2</button>
			<button @click="view='custom3'">出现custome3</button>
			<div :is="view"></div>
			<component  :is="view"></component>
		</div>
		
		<script>
			// 动态组件

			Vue.component('custom1',{
				template: `<div>custom1</div>`
			})
			Vue.component('custom2',{
				template: `<div>custom2</div>`
			})

			Vue.component('custom3',{
				template: `<div>custom3</div>`
			})


			let vm = new Vue({
				data:{
					view: ''
				},
				created(){
					setTimeout( () => {
						this.view = 'custom2';	
					},3000)
				}
			})

			vm.$mount('#app');	
		</script>
	</body>
</html>